package org.nepu.srr.domain.operatorrisk.converter;

import cn.hutool.json.JSONUtil;
import org.nepu.srr.domain.operatorrisk.vo.OperatorRisk;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

@Convert
public class OperatorRiskConverter implements AttributeConverter<OperatorRisk, String> {
    @Override
    public String convertToDatabaseColumn(OperatorRisk operatorRisk) {
        return JSONUtil.toJsonStr(operatorRisk);
    }

    @Override
    public OperatorRisk convertToEntityAttribute(String s) {
        return JSONUtil.toBean(s, OperatorRisk.class);
    }
}
